package com.qf.controller;

import com.qf.entity.Result;
import com.qf.pojo.OrderInfo;
import com.qf.service.OrderService;
import com.qf.service.OrderService1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 体检预约
 */
@RestController
@RequestMapping("/orderinfo1")
public class OrderController1 {

    @Autowired
    OrderService1 orderService;

    /**
     * 体检预约存入信息
     */
    @RequestMapping("/add")
    public Result add(@RequestBody Map map){
//        HashMap<Object, Object> map1 = new HashMap<>();
//        map1.put("setmealId","12");
//        map1.put("name","张三");
//        map1.put("sex","0");
//        map1.put("phone","18457537836");
//        map1.put("idCard","1231232132131233");
//        map1.put("birthday",new Date());
//        map1.put("orderDate","2019-03-05");
        System.out.println(map);
        try {
           map.put("orderType","微信预约");
           Result result = orderService.order(map);
            System.out.println(result);
            if (result.getMsg()!="success"){
                Result.error(result.getMsg());
            }
           return Result.success(result.getData());
       }catch (Exception e){
           e.printStackTrace();
           return Result.error("预约失败");
       }
    }

    /**
     * 预约成功界面的套餐信息
     */
    @RequestMapping("/findById")
    public Result findById(Integer id){
        try{
            Map map = orderService.findById(id);
            //查询预约信息成功
            return Result.success(map);
        }catch (Exception e){
            e.printStackTrace();
            //查询预约信息失败
            return Result.error("查询预约信息失败");
        }
    }
}
